<!DOCTYPE html>
<html>

<head>
    <title>黑马顺风车</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../css/jquery.mobile-1.4.5.min.css">
    <script src="../js/jquery-1.11.3.min.js"></script>
    <script src="../js/jquery.mobile-1.4.5.min.js"></script>
    <link rel="stylesheet" href="../css/common.css" />
    <script src="../js/common.js"></script>

    <script>


        var i;

        $(function () {

            $('#go').click(function () {

                i = setInterval(function () {
                    //以大概的中国中心坐标点为基准，上下经纬度在10之间随机生成
                    var lng = random(95, 120);
                    var lat = random(25, 42);
                    var driverTripId = $('#tripId').val();
                    $.ajax({
                        type: "POST",
                        url: "/stroke/api/sendStartGeo",
                        cache: false,
                        data: JSON.stringify({
                            key: "random_key",
                            location: {
                                lat: lat,
                                lon: lng
                            },
                            name: "随机位置",
                            ratio:random(1,100)
                        }),
                        success: function (d) {
                            console.log(d);
                        }
                    });
                    $('#pageone').prepend('<p>' + driverTripId + '  :  ' + lng + ' , ' + lat + '</p>');
                }, random(1000,5000));

            });

            $('#stop').click(function () {
                clearInterval(i);
            })

            $('#tripId').focus(function () {
                $(this).val('')
            })

        })




    </script>

</head>

<body>

    <h2>mock灌入打车分布监控数据</h2>
    <!-- <input id="tripId" placeholder="输入司机行程id"> -->
    <button id="go" style="display: inline; width: 150px;">移动</button>
    <button id="stop" style="display: inline; width: 150px;">停止</button>

    <div id="pageone">
    </div>
</body>

</html>